package model;

import java.util.Date;

public class BuyOrder extends Order implements Comparable<BuyOrder> {
	private static final long serialVersionUID = 5887321406718515441L;

	public BuyOrder(int userId, String transactionId, Date date, String stockname,
			int number, int price) {
		super(userId, transactionId, date, stockname, number, price);
	}

	@Override
	public int compareTo(BuyOrder o) {
		// compare on price, if equal, on order time
		if(this.getPrice() < o.getPrice()) {
			return 1;
		} else if(this.getPrice() > o.getPrice()) {
			return -1;
		} else {
			return this.getDate().compareTo(o.getDate());
		}
	}

}
